
<!doctype html>
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:th="http://www.thymeleaf.org"
       xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">

<body >

<nav th:fragment="topbar" class="navbar navbar-expand-lg navbar-dark fixed-top bg-dark">
    <a class="navbar-brand" href="/index">LOGO 'ᴗ' </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse"
            aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarCollapse">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href="/index">网站首页 </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="/buyer/cart/cartPage">买家板块 </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="/seller/shop/shopManagementPage">卖家板块 </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="/admin/shop/ManagementPage" sec:authorize="hasRole('ADMIN')">管理员板块 </a>
            </li>

            <form class="form-inline mt-2 mt-md-0">
                <input class="form-control mr-sm-2" type="text" placeholder="搜索店铺或商品" aria-label="Search">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜一搜</button>
            </form>
        </ul>

        <!--登录及个人信息区域,在js里通过session判断来切换显示信息-->
        <ul class="float-right navbar-nav">
            <li  class="nav-item">
                <div class="row" id="user">
                    <img id="userHeadImg" class="rounded-circle figure-img" src="\images\testhead.jpg" alt="头像"  sec:authorize="isAuthenticated()"  />
                    <a id="login" href="/login" class="nav-link" th:if="${null == session.user }" sec:authorize="isAnonymous()" >登录</a>
                    <a id="register" href="/common/register/registerUserPage" class="nav-link"  sec:authorize="isAnonymous()" >注册</a>
                    <a id="userCenter" href="#" class="nav-link" sec:authorize="isAuthenticated()" sec:authentication="name" ></a>
                    <a id="exit"href="/logout" class="nav-link" sec:authorize="isAuthenticated()" >安全退出</a>
                </div>
            </li>
        </ul>
    </div>
</nav>

</body>
</html>
